package my.tutorial.javacore.test.analytic;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Java Test 2 Objects 
 */
public class Student implements Comparable<Student>{

	private String studentId;
	private String name;
	
	public Student(String studentId, String name){
		this.studentId=studentId;
		this.name=name;
	}

	public String getStudentId() {
		return studentId;
	}

	public void setStudentId(String studentId) {
		this.studentId = studentId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public int compareTo(Student student) {
		return name.compareTo(student.name);
	}
	
	public static void main(String[] args){
		List<Student> studentsList = new ArrayList<Student>();
		
		studentsList.add(new Student("0054", "Albert Einstein"));
		studentsList.add(new Student("1234", "Gottfried Wilhelm Leibniz"));
		studentsList.add(new Student("5421", "Carl Friedrich Gauss"));
		
		Collections.sort(studentsList);
		for(Student student:studentsList){
			System.out.println("ID: "+student.getStudentId()+" Name: "+student.getName());
		}
	}


}
